/*
 * @Author: xiaorao 2930367909@qq.com
 * @Date: 2025-02-21 11:02:59
 * @LastEditors: xiaorao 2930367909@qq.com
 * @LastEditTime: 2025-02-21 11:03:13
 * @FilePath: \common\CommonVue\src\api\file.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

//blob文件流下载
export function downloadFile(blob: any, fileName: string) {
  const downloadElement = document.createElement("a");
  const objectUrl = window.URL.createObjectURL(blob); // 创建下载的链接
  downloadElement.href = objectUrl;
  downloadElement.download = fileName || "data.xls"; // 下载后文件名
  document.body.appendChild(downloadElement);
  downloadElement.click(); // 点击下载
  document.body.removeChild(downloadElement); // 下载完成移除元素
  window.URL.revokeObjectURL(objectUrl); // 释放blob对象
}
